//
//  MDeviceSwitchCell.m
//  Mask
//
//  Created by 郭子一 on 2020/10/3.
//  Copyright © 2020 郭子一. All rights reserved.
//

#import "MDeviceSwitchCell.h"

@interface MDeviceSwitchCell ()

@property (nonatomic, strong) UILabel *nameLable; // 标题
@property (nonatomic, strong) UILabel *deviceTypeLable; // 型号
@property (nonatomic, strong) UILabel *batteryLable; // 剩余电量
@property (nonatomic, strong) UIImageView *deviceImg; // 图片
@property (nonatomic, strong) UILabel *stateLable; // 状态

@end

@implementation MDeviceSwitchCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = UIColor.clearColor;
        [self makeUI];
    }
    return self;
}

- (void)makeUI
{
    UIView *view = [[UIView alloc] init];
    [self.contentView addSubview:view];
    view.layer.backgroundColor = [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0].CGColor;
    view.layer.cornerRadius = 10;
    view.layer.shadowColor = [UIColor colorWithRed:93/255.0 green:102/255.0 blue:147/255.0 alpha:0.15].CGColor;
    view.layer.shadowOffset = CGSizeMake(0,2);
    view.layer.shadowOpacity = 1;
    view.layer.shadowRadius = 8;
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(8);
        make.left.offset(15);
        make.right.offset(-15);
        make.bottom.offset(-7);
    }];
    
    self.nameLable = [[UILabel alloc] init];
    self.nameLable.text = @"我的设备1";
    self.nameLable.textColor = RGB_VALUE(0x5C5D66);
    self.nameLable.font = JSS_FONT_6;
    [view addSubview:self.nameLable];
    [self.nameLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.offset(15);
        make.height.mas_equalTo(22);
        make.right.offset(-140);
    }];
    
    self.deviceTypeLable = [[UILabel alloc] init];
    self.deviceTypeLable.text = @"设备型号：白色 No1";
    self.deviceTypeLable.textColor = RGB_VALUE(0x879099);
    self.deviceTypeLable.font = JSS_FONT_3;
    [view addSubview:self.deviceTypeLable];
    [self.deviceTypeLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.nameLable.mas_bottom).offset(13);
        make.left.offset(15);
        make.height.mas_equalTo(18);
        make.right.offset(-140);
    }];
    
    self.batteryLable = [[UILabel alloc] init];
    self.batteryLable.text = @"剩余电量：99%";
    self.batteryLable.textColor = RGB_VALUE(0x879099);
    self.batteryLable.font = JSS_FONT_3;
    [view addSubview:self.batteryLable];
    [self.batteryLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.deviceTypeLable.mas_bottom).offset(1);
        make.left.offset(15);
        make.height.mas_equalTo(18);
        make.right.offset(-140);
    }];
    
    self.deviceImg = [[UIImageView alloc] init];
    self.deviceImg.image = [UIImage imageNamed:@""];
    self.deviceImg.backgroundColor = UIColor.cyanColor;
    [view addSubview:self.deviceImg];
    [self.deviceImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(15);
        make.height.mas_equalTo(77);
        make.width.mas_equalTo(108);
        make.right.offset(-25);
    }];
    
    self.stateLable = [[UILabel alloc] init];
    self.stateLable.text = @" 已连接 ";
    self.stateLable.textColor = RGB_VALUE(0xFFFFFF);
    self.stateLable.font = JSS_FONT_2;
    self.stateLable.backgroundColor = RGB_VALUE(0x00C3FE);
    self.stateLable.alpha = 0.9;
    self.stateLable.layer.cornerRadius = 11;
    self.stateLable.layer.masksToBounds = YES;
    [view addSubview:self.stateLable];
    [self.stateLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(15);
        make.height.mas_equalTo(22);
        make.right.offset(-20);
    }];
    [self.stateLable setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
}

@end
